// deviceVideo.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    video: '',
    size: '',
    bigShelfNum: '',
    identityNum: '',
    url:app.globalData.requestURL+'upload/uploadImgTest',
    path: '',//文件本地路径
    name: '',//name标识符
    imagesType: '',//自定义上传的目录路径
  },
  addVideo: function () {
    var that = this
    //视频上传代码
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: 'back',
      success: function (res) {
        that.setData({
          name: "deviceVideo",
          video: res.tempFilePath,
          path : res.tempFilePath,
          size: (res.size / (1024 * 1024)).toFixed(2),
          imagesType: 'device/' + that.data.identityNum + "/" + that.data.bigShelfNum
        });
        app.uploadVideo(that.data);
        app.videoResponseUrlReadyCallback = imgResponseUrl => {
          wx.setStorageSync('video', imgResponseUrl)
          that.setData({
            video: wx.getStorageSync('video')
          })
        };
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      bigShelfNum: wx.getStorageSync("factoryNum"),
      identityNum: wx.getStorageSync('identification')
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})